package lysjmaster.base.auth.controller;

import lombok.extern.slf4j.Slf4j;
import lysjmaster.base.auth.domain.Role;
import lysjmaster.base.auth.service.PermissionService;
import lysjmaster.base.auth.service.RolePermissionService;
import lysjmaster.base.auth.service.RoleService;
import lysjmaster.base.common.CommonConstant;
import lysjmaster.base.common.annotation.SystemLog;
import lysjmaster.base.common.spring.base.BaseContent;
import lysjmaster.base.common.spring.base.BaseController;
import lysjmaster.base.common.spring.base.BaseService;
import lysjmaster.base.common.spring.pagination.PageRequestDTO;
import lysjmaster.base.common.validation.annotation.Valid;
import lysjmaster.base.common.web.Resp;
import lysjmaster.base.common.web.RespUtil;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @author Created by zk on 2019-12-05 2:27
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/auth/role")
public class RoleController extends BaseController<Role,PageRequestDTO> {
    @Resource
    private RoleService roleService;

    @Override
    public BaseService<Role> getService() {
        return roleService;
    }

    @Override
    public Resp list(PageRequestDTO condition) {
        Page<Role> roles = roleService.roleList(condition);
        return RespUtil.success(roles);
    }

    @PostMapping(value = "/edit_role_perm")
    public Resp editRolePerm(String id, String[] permIds){
        roleService.editRolePerm(id,permIds);
        return RespUtil.success("权限分配成功");
    }

    @Override
    public Resp delete(String[] ids) {
        roleService.deleteRole(ids);
        return RespUtil.success("删除成功");
    }


}
